#encoding:utf-8
import json
import re
from cgi import parse_qs,escape


def api_test(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    url=environ['PATH_INFO'][1:]
    print url
    query=parse_qs(environ['QUERY_STRING'])
    #print query
    data= query.get("name",[''])[0]
    js = {"code": 200, "data":data }
    return json.dumps(js)

def api_db(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    url=environ['PATH_INFO'][1:]
    print url
    query=parse_qs(environ['QUERY_STRING'])
    data= query.get("name",[''])[0]
    js = {"code": 200, "data":data }
    return json.dumps(js)
